package com.wwf.sqlsession;

import com.wwf.config.XmlConfigBuilder;
import com.wwf.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuild {
    public SqlSessionFactory build(InputStream in) throws PropertyVetoException, DocumentException {
        //1、读取配置文件赋值到Configuration和MappedStatement
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseXmlConfig(in);
        //2、构建SqlsessionFactory
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return defaultSqlSessionFactory;
    }
}
